home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / axcool / ppbutton.pag < prev    next >
Encoding:
Text File  |  1998-10-27  |  10.4 KB  |  366 lines

  1. VERSION 5.00
  2. Begin VB.PropertyPage ppButtons 
  3.    Caption         =   "General"
  4.    ClientHeight    =   2685
  5.    ClientLeft      =   0
  6.    ClientTop       =   0
  7.    ClientWidth     =   5625
  8.    PaletteMode     =   0  'Halftone
  9.    ScaleHeight     =   2685
  10.    ScaleWidth      =   5625
  11.    Begin VB.PictureBox imgButton 
  12.       Height          =   690
  13.       Left            =   3735
  14.       ScaleHeight     =   630
  15.       ScaleWidth      =   630
  16.       TabIndex        =   18
  17.       Top             =   1440
  18.       Width           =   690
  19.    End
  20.    Begin VB.CheckBox chkDropDown 
  21.       Caption         =   "Drop-down Button"
  22.       Height          =   240
  23.       Left            =   1350
  24.       TabIndex        =   17
  25.       Top             =   2160
  26.       Width           =   1680
  27.    End
  28.    Begin VB.CheckBox chkVisible 
  29.       Caption         =   "Visible"
  30.       Height          =   240
  31.       Left            =   1350
  32.       TabIndex        =   10
  33.       Top             =   1890
  34.       Width           =   870
  35.    End
  36.    Begin VB.CheckBox chkEnabled 
  37.       Caption         =   "Enabled"
  38.       Height          =   240
  39.       Left            =   2250
  40.       TabIndex        =   9
  41.       Top             =   1890
  42.       Width           =   915
  43.    End
  44.    Begin VB.TextBox txtIndex 
  45.       BackColor       =   &H8000000F&
  46.       Height          =   285
  47.       Left            =   1350
  48.       Locked          =   -1  'True
  49.       TabIndex        =   8
  50.       TabStop         =   0   'False
  51.       Top             =   225
  52.       Width           =   690
  53.    End
  54.    Begin VB.TextBox txtCaption 
  55.       Height          =   285
  56.       Left            =   1350
  57.       TabIndex        =   7
  58.       Top             =   540
  59.       Width           =   1770
  60.    End
  61.    Begin VB.TextBox txtTag 
  62.       Height          =   285
  63.       Left            =   1350
  64.       TabIndex        =   6
  65.       Top             =   1215
  66.       Width           =   1770
  67.    End
  68.    Begin VB.TextBox txtToolTip 
  69.       Height          =   285
  70.       Left            =   1350
  71.       TabIndex        =   5
  72.       Top             =   1530
  73.       Width           =   1770
  74.    End
  75.    Begin VB.ComboBox cboStyle 
  76.       Height          =   315
  77.       ItemData        =   "ppButtons.pgx":0000
  78.       Left            =   1350
  79.       List            =   "ppButtons.pgx":0013
  80.       Style           =   2  'Dropdown List
  81.       TabIndex        =   4
  82.       Top             =   855
  83.       Width           =   1770
  84.    End
  85.    Begin VB.HScrollBar hsbButton 
  86.       Height          =   285
  87.       Left            =   2115
  88.       TabIndex        =   3
  89.       Top             =   225
  90.       Width           =   510
  91.    End
  92.    Begin VB.CommandButton cmdImage 
  93.       Height          =   330
  94.       Left            =   3375
  95.       Picture         =   "ppButtons.pgx":0060
  96.       Style           =   1  'Graphical
  97.       TabIndex        =   2
  98.       ToolTipText     =   "Load Image"
  99.       Top             =   1440
  100.       UseMaskColor    =   -1  'True
  101.       Width           =   330
  102.    End
  103.    Begin VB.CommandButton cmdButton 
  104.       Caption         =   "I&nsert Button"
  105.       Height          =   330
  106.       Index           =   0
  107.       Left            =   4140
  108.       TabIndex        =   0
  109.       Top             =   180
  110.       Width           =   1320
  111.    End
  112.    Begin VB.CommandButton cmdButton 
  113.       Caption         =   "&Remove Button"
  114.       Enabled         =   0   'False
  115.       Height          =   330
  116.       Index           =   1
  117.       Left            =   4140
  118.       TabIndex        =   1
  119.       Top             =   540
  120.       Width           =   1320
  121.    End
  122.    Begin VB.Label Label1 
  123.       Caption         =   "Index:"
  124.       Height          =   195
  125.       Index           =   0
  126.       Left            =   225
  127.       TabIndex        =   16
  128.       Top             =   270
  129.       Width           =   825
  130.    End
  131.    Begin VB.Label Label1 
  132.       Caption         =   "Caption:"
  133.       Height          =   195
  134.       Index           =   1
  135.       Left            =   225
  136.       TabIndex        =   15
  137.       Top             =   585
  138.       Width           =   825
  139.    End
  140.    Begin VB.Label Label1 
  141.       Caption         =   "Style:"
  142.       Height          =   195
  143.       Index           =   3
  144.       Left            =   225
  145.       TabIndex        =   14
  146.       Top             =   900
  147.       Width           =   825
  148.    End
  149.    Begin VB.Label Label1 
  150.       Caption         =   "Tag:"
  151.       Height          =   195
  152.       Index           =   4
  153.       Left            =   225
  154.       TabIndex        =   13
  155.       Top             =   1260
  156.       Width           =   825
  157.    End
  158.    Begin VB.Label Label1 
  159.       Caption         =   "ToolTip Text:"
  160.       Height          =   195
  161.       Index           =   5
  162.       Left            =   225
  163.       TabIndex        =   12
  164.       Top             =   1575
  165.       Width           =   1095
  166.    End
  167.    Begin VB.Label Label1 
  168.       Caption         =   "Image:"
  169.       Height          =   195
  170.       Index           =   6
  171.       Left            =   3735
  172.       TabIndex        =   11
  173.       Top             =   1170
  174.       Width           =   825
  175.    End
  176. End
  177. Attribute VB_Name = "ppButtons"
  178. Attribute VB_GlobalNameSpace = False
  179. Attribute VB_Creatable = True
  180. Attribute VB_PredeclaredId = False
  181. Attribute VB_Exposed = True
  182. Private bFirst As Boolean
  183.  
  184. Private Sub cboStyle_Click()
  185.   Changed = True
  186. End Sub
  187.  
  188. Private Sub chkDropDown_Click()
  189.   Changed = True
  190. End Sub
  191.  
  192. Private Sub chkEnabled_Click()
  193.   Changed = True
  194. End Sub
  195.  
  196. Private Sub chkVisible_Click()
  197.   Changed = True
  198. End Sub
  199.  
  200. Private Sub cmdButton_Click(Index As Integer)
  201. Select Case Index
  202. Case 0      'insert button
  203.     If SelectedControls(0).Count = 0 Then EnableAll: cmdButton(1).Enabled = True
  204.     SelectedControls(0).AddItem
  205.     txtIndex = SelectedControls(0).Count
  206.     txtCaption = ""
  207.     cboStyle.ListIndex = 0
  208.     txtToolTip = ""
  209.     txtTag = ""
  210.     chkVisible.value = 1
  211.     chkEnabled.value = 1
  212.     chkDropDown.value = 0
  213.     Set imgButton.Picture = Nothing
  214.     SaveItem SelectedControls(0).Count
  215.     hsbButton.Min = 1
  216.     hsbButton.Max = SelectedControls(0).Count
  217.     hsbButton.value = SelectedControls(0).Count
  218.    
  219. Case 1      'remove button
  220.     If SelectedControls(0).Count > 0 Then
  221.       SelectedControls(0).Remove hsbButton.value
  222.       If SelectedControls(0).Count > 0 Then
  223.         hsbButton.Max = SelectedControls(0).Count
  224.         hsbButton.value = 1
  225.       Else
  226.         hsbButton.Max = 1
  227.         hsbButton.value = 1
  228.         cmdButton(1).Enabled = False
  229.         txtIndex = "1"
  230.         txtCaption = ""
  231.         txtToolTip = ""
  232.         txtTag = ""
  233.         chkVisible.value = 0
  234.         chkEnabled.value = 0
  235.         chkDropDown.value = 0
  236.         cboStyle.ListIndex = 0
  237.         DisableAll
  238.       End If
  239.       SelectedControls(0).RedrawButtons
  240.     Else
  241.       Beep
  242.       MsgBox "No buttons to remove", vbOKOnly, "User Error"
  243.     End If
  244. End Select
  245. End Sub
  246.  
  247. Private Sub cmdImage_Click()
  248.   Dim Common As New clsCommonDialog
  249.   Common.DialogTitle = "Load Picture"
  250.   Common.InitDir = App.Path
  251.   Common.Filter = "All Picture Files|*.bmp;*.ico;*.rle;*.wmf;*.emf;*.gif;*.jpg"
  252.   Common.ShowOpen
  253.   If Not Common.Cancelled Then
  254.     imgButton.Picture = LoadPicture(Common.FileName)
  255.   Else
  256.     Set imgButton.Picture = Nothing
  257.   End If
  258.   Changed = True
  259. End Sub
  260.  
  261. Private Sub hsbButton_Change()
  262.   If SelectedControls(0).Count > 0 Then
  263.     txtIndex = hsbButton.value
  264.     txtCaption = SelectedControls(0).Item(hsbButton.value).Caption
  265.     txtToolTip = SelectedControls(0).Item(hsbButton.value).ToolTipText
  266.     txtTag = SelectedControls(0).Item(hsbButton.value).Tag
  267.     cboStyle.ListIndex = SelectedControls(0).Item(hsbButton.value).Style
  268.     Set imgButton.Picture = IIf(SelectedControls(0).Item(hsbButton.value).Bitmap Is Nothing, Nothing, SelectedControls(0).Item(hsbButton.value).Bitmap)
  269.     chkVisible = SelectedControls(0).Item(hsbButton.value).Visible
  270.     chkEnabled = SelectedControls(0).Item(hsbButton.value).Enabled
  271.     chkDropDown = SelectedControls(0).Item(hsbButton.value).DropDown
  272.   End If
  273.   Changed = False
  274. End Sub
  275.  
  276. Private Sub hsbButton_GotFocus()
  277.   If txtCaption.Enabled Then txtCaption.SetFocus
  278. End Sub
  279.  
  280. Private Sub PropertyPage_ApplyChanges()
  281.   SaveItem hsbButton.value
  282. End Sub
  283.  
  284. Public Sub SaveItem(Index As Integer)
  285.   If SelectedControls(0).Count > 0 Then
  286.     SelectedControls(0).Item(Index).Caption = txtCaption
  287.     SelectedControls(0).Item(Index).ToolTipText = txtToolTip
  288.     SelectedControls(0).Item(Index).Tag = txtTag
  289.     SelectedControls(0).Item(Index).Style = cboStyle.ListIndex
  290.     Set SelectedControls(0).Item(Index).Bitmap = IIf(imgButton.Picture Is Nothing, Nothing, imgButton.Picture)
  291.     SelectedControls(0).Item(Index).Visible = chkVisible
  292.     SelectedControls(0).Item(Index).Enabled = chkEnabled
  293.     SelectedControls(0).Item(Index).DropDown = chkDropDown
  294.     SelectedControls(0).RedrawButtons
  295.   End If
  296. End Sub
  297.  
  298. Private Sub PropertyPage_Initialize()
  299.   bFirst = True     'this is used to preven SelectionChanged code from firing more than once
  300. End Sub
  301.  
  302. Private Sub PropertyPage_SelectionChanged()
  303. If bFirst Then
  304. bFirst = False
  305. If SelectedControls(0).Count > 0 Then
  306.     EnableAll
  307.     cmdButton(1).Enabled = True
  308.     hsbButton.Min = 1
  309.     hsbButton.Max = SelectedControls(0).Count
  310.     hsbButton.value = 1
  311. Else
  312.     hsbButton.Min = 1
  313.     hsbButton.Max = 1
  314.     hsbButton.value = 1
  315.     DisableAll
  316.     cmdButton(1).Enabled = False
  317. End If
  318. End If
  319. End Sub
  320.  
  321. Private Sub EnableAll()
  322.   hsbButton.Enabled = True
  323.   cmdImage.Enabled = True
  324.   chkVisible.Enabled = True
  325.   chkEnabled.Enabled = True
  326.   chkDropDown.Enabled = True
  327.   
  328.   txtCaption.Enabled = True
  329.   txtCaption.BackColor = vbWindowBackground
  330.   txtTag.Enabled = True
  331.   txtTag.BackColor = vbWindowBackground
  332.   txtToolTip.Enabled = True
  333.   txtToolTip.BackColor = vbWindowBackground
  334.   cboStyle.Enabled = True
  335.   cboStyle.BackColor = vbWindowBackground
  336. End Sub
  337.  
  338. Private Sub DisableAll()
  339.   hsbButton.Enabled = False
  340.   cmdImage.Enabled = False
  341.   chkVisible.Enabled = False
  342.   chkEnabled.Enabled = False
  343.   chkDropDown.Enabled = False
  344.   
  345.   txtCaption.Enabled = False
  346.   txtCaption.BackColor = vbButtonFace
  347.   txtTag.Enabled = False
  348.   txtTag.BackColor = vbButtonFace
  349.   txtToolTip.Enabled = False
  350.   txtToolTip.BackColor = vbButtonFace
  351.   cboStyle.Enabled = False
  352.   cboStyle.BackColor = vbButtonFace
  353. End Sub
  354.  
  355. Private Sub txtCaption_Change()
  356.   Changed = True
  357. End Sub
  358.  
  359. Private Sub txtTag_Change()
  360.   Changed = True
  361. End Sub
  362.  
  363. Private Sub txtToolTip_Change()
  364.   Changed = True
  365. End Sub
  366.